#ifndef ICON_BUTTON_H
#define ICON_BUTTON_H

#include <gtk/gtk.h>
#include <goocanvas.h>


namespace View {

  enum IconState {
    ICON_STATE_HIDE = 0,
    ICON_STATE_BG_ONSHOW,
    ICON_STATE_MG_ONSHOW,
    ICON_STATE_FG_ONSHOW
  };

  class IconButton
  {
  private:
    gdouble coordinatesX;
    gdouble coordinatesY;
    
    GooCanvasItem *parent;
    GooCanvasItem *canvas;
    GooCanvasItem *normalBackground;
    GooCanvasItem *mouseOverBackground;
    GooCanvasItem *fadeBackground;
    IconState iconState;
    bool frozen;
    
    bool SetState(IconState newState);
    IconState GetState(){ return iconState; }

  protected:
    void *data;
    virtual bool OnClicked() = 0 ;
    
  public:
    IconButton(GooCanvasItem * newParent,gdouble x,gdouble y,GdkPixbuf *bg,GdkPixbuf *mg,GdkPixbuf *fg);
    virtual ~IconButton();
    bool SetData( void *newData) ;
    bool MoveTo(double xOffset, double yOffset);

    bool Hide();
    bool Show();
    bool Fade();
    bool UnFade();

    friend gboolean on_icon_press_event_cb (GooCanvasItem *item,
					    GooCanvasItem *target_item,
					    GdkEventButton *event,
					    gpointer user_data);
    friend gboolean on_motion_notify_event_cb (GooCanvasItem  *item,
					       GooCanvasItem  *target_item,
					       GdkEventMotion *event,
					       gpointer user_data);
    friend gboolean on_leave_notify_event_cb (GooCanvasItem  *item,
					      GooCanvasItem  *target_item,
					      GdkEventMotion *event,
					      gpointer user_data);
    
  };

}

#endif
